 /**
 *  xml工具类;
 * @author    KeJun Zheng
 * @copyright (c) 2013,  Amdocs
 * @version   0.1
 * @date      <ul>
 * <li>2013-08-07</li>
 * </ul>
 *
 */
//add a new child in current xml node;
function xmlAddNode(pNode,cName,cText){
	var xmlDoc = pNode.ownerDocument;
	var newNode = xmlDoc.createElement(cName);
	if(cText)newNode.text = cText;
	pNode.appendChild(newNode);
	return newNode;
}

//remove all child nodes in current xml node;
function xmlClearNodes(pNode){
	var oNodeList = pNode.childNodes;
	//for (var i=0; i<oNodeList.length; i++) {
	for (var i=oNodeList.length-1; i>=0; i--) {
	  pNode.removeChild(oNodeList.item(i));
	}
	return pNode;
}

function xmlCloneAttrs(source, target){
	var xAttrs = source.attributes;
	for(var i=0;i<xAttrs.length;i++){
		target.setAttribute(xAttrs[i].name,xAttrs[i].value);
	}
	return target;
}

//create new xml document with /root/request;
function getEmptyRequest(){
	var xmlDoc = getDomHandle();
	var rootNode = xmlDoc.createElement("root");
		xmlDoc.documentElement = rootNode;
	var reuestNode=xmlAddNode(rootNode,"request");
	return reuestNode;
}



